/**
 * 
 */
package net.phoenix.repository.query.jql;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

/**
 * @author lixf
 * 
 */
public class QueryTranslater {
	private Stack<String> stack;
	private List<String> tables;
	private List<String> parameters;

	public QueryTranslater() {
		this.stack = new Stack<String>();
		this.tables = new ArrayList<String>();
		this.parameters = new ArrayList<String>();
	}

	public void addSource(String table) {
		String lowercase = table.toLowerCase();
		if (!this.tables.contains(lowercase))
			this.tables.add(lowercase);
	}

	public void push(String condition) {
		this.stack.push(condition);
	}

	public String pop() {
		return this.stack.pop();
	}

	public void addParameter(String name) {
		if (!this.parameters.contains(name))
			this.parameters.add(name);
	}

	public String getQuery() {
		return this.stack.pop();
	}
}
